package cn.com.sparkle.paxos.event;

import cn.com.sparkle.paxos.iomodel.protobuffmessage.PaxosMessages.SuccessfulRecord;

//import cn.com.sparkle.paxos.stablestorage.model.SuccessfulRecord;

public abstract class InstanceExecuteEvent implements Event {
	public final static int EVENT_FINISH_EXECUTE = 1;

	@Override
	public void event(Object... args) {
		int type = (Integer) args[0];
		switch (type) {
		case EVENT_FINISH_EXECUTE:
			eventExecuted((SuccessfulRecord) args[1]);
			break;
		default:
			throw new RuntimeException("not supported argument:" + type);
		}
	}

	public abstract void eventExecuted(SuccessfulRecord record);

	public static void doEventExecutedEvent(EventsManager eventsManager,
			SuccessfulRecord record) {
		eventsManager.doEvent(InstanceExecuteEvent.class, EVENT_FINISH_EXECUTE,
				record);
	}

}
